CODAP-281: animate slider axis when value is edited outside bounds#2413
CODAP-281: animate slider axis when value is edited outside bounds#2413
Conversation
When the user edits the slider value text to a value outside the current axis range, the axis now smoothly animates to encompass the new value, matching V2 behavior. The thumb slides into view along with the axis. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
codap-v3
|
||||||||||||||||||||||||||||
| Project |
codap-v3
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 02m 13s |
| Commit |
|
| Committer | eireland |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
4
|
| View all changes introduced in this branch ↗︎ | |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2413 +/- ##
========================================
Coverage 85.50% 85.50%
========================================
Files 755 756 +1
Lines 41873 41931 +58
Branches 9962 10376 +414
========================================
+ Hits 35802 35853 +51
- Misses 6059 6063 +4
- Partials 12 15 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…mation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds smooth axis rescaling animation when a slider’s value is edited via the text field to a value outside the current axis bounds, matching prior (V2) behavior while keeping undo/redo scoped to the final persisted bounds.
Changes:
- Introduces a
useSliderAxisAnimation()hook that animates the axis domain viarequestAnimationFrameusing the axis model’s volatile dynamic domain. - Updates
SliderModelto track an “axis animating” state and skip value clamping during animation-driven domain updates. - Adds
clearDynamicDomain()to numeric axis models and wires the editable value field to use the new animation hook.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| v3/src/components/slider/use-slider-axis-animation.ts | New hook implementing animated axis domain transitions for out-of-range typed values. |
| v3/src/components/slider/slider-model.ts | Adds _isAxisAnimating flag and gates axis-domain reaction to avoid clamping during animation. |
| v3/src/components/slider/editable-slider-value.tsx | Routes blur-submit value edits through the new animation hook instead of direct model changes. |
| v3/src/components/axis/models/base-numeric-axis-model.ts | Adds clearDynamicDomain() helper for resetting volatile dynamic domain overrides. |
Comments suppressed due to low confidence (1)
v3/src/components/slider/slider-model.ts:160
- The new
_isAxisAnimatinggate changesaxis.domainreaction behavior but isn't covered by existingSliderModeltests. Please add/extend unit tests to verify (1) when_isAxisAnimatingis true, domain changes do not clampvalue, and (2) once animation ends/cancels, the value is clamped again if it is outside the current domain.
addDisposer(self, reaction(
() => self.axis.domain,
([axisMin, axisMax]) => {
// skip constraining value during axis animation (value is intentionally outside bounds)
if (self._isAxisAnimating) return
// keep the thumbnail within axis bounds when axis bounds are changed
if (self.value < axisMin) self.setDynamicValueIfDynamic(axisMin)
if (self.value > axisMax) self.setDynamicValueIfDynamic(axisMax)
}, { name: "SliderModel [axis.domain]" }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review feedback: - Guard cancelAnimation with isAlive() to prevent calling MST actions on destroyed nodes during unmount - Set isAxisAnimating false before clearing dynamic domain so the axis domain reaction can constrain the value if needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kswenson
left a comment
There was a problem hiding this comment.
👍 Looks good -- the following review was developed in conjunction with Claude Code 🤖.
PR Review Summary
Changes: 4 files, +122 / -15 lines
What it does
When the user types a slider value outside the current axis range, the axis now smoothly animates (~500ms ease-out cubic) to encompass the new value, with the thumb sliding into view. Previously the axis would snap instantly. This matches V2 behavior.
The approach
A new useSliderAxisAnimation hook applies the model change atomically first (for clean undo/redo), then animates the visual transition via the axis volatile dynamicMin/dynamicMax using requestAnimationFrame. A _isAxisAnimating flag prevents the domain reaction from clamping the value during animation.
Assessment
Clean, well-structured implementation. Edge cases handled well (rapid edits, unmount, undo during animation, model destruction). All CI passing including full regression suite.
Commits during review
- Replace non-null assertions with const assignment in useSliderAxisAnimation
- Add isAlive guard and fix cleanup ordering in useSliderAxisAnimation (Copilot feedback)
Summary
Fixes CODAP-281
Test plan
Generated with Claude Code